angular.module('avoidMistakes.services')

.factory('HomeService', ['$q',  '$cordovaToast', '$http',
	function($q,  $cordovaToast,  $http) {
	    function getOrderData(orderId) {
	        var deferred = $q.defer();
	        
	        $http({
	            method: 'GET',
	            url: 'http://tapi.u9hub.com/api/so/info',
	            params: {
	                'id': orderId   
	            }
	        }).success(function(data) {
	            console.log(data);
	            deferred.resolve(data);

	        }).error(function(err) {
	            console.log(err);
	            deferred.reject(err);
	        });
	        return deferred.promise;
	    }

	    function getCurrentOrderData(orderId) {
	        var deferred = $q.defer();
	        
	        $http({
	            method: 'GET',
	            url: 'http://tapi.u9hub.com/api/so/produce',
	            params: {
	                 
	            }
	        }).success(function(data) {
	            console.log(data);
	            deferred.resolve(data);

	        }).error(function(err) {
	            console.log(err);
	            deferred.reject(err);
	        });
	        return deferred.promise;
	    }

	    return {
            getOrderData: getOrderData,
            getCurrentOrderData:getCurrentOrderData
        };
	}
]);